package com.example.demo.controller;

import com.example.demo.entity.Designer;
import com.example.demo.service.ContractService;
import com.example.demo.service.CustomerService;
import com.example.demo.service.MeasureService;
import com.example.demo.service.PlanService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/count")
public class CountController {
    @Resource
    private CustomerService customerService;
    @Resource
    private MeasureService measureService;
    @Resource
    private PlanService planService;
    @Resource
    private ContractService contractService;

    @RequestMapping("/list")
    @ResponseBody
    public List<Integer> mysearch(HttpSession session){
        Designer designer =(Designer) (session.getAttribute("designer"));
        String desId = designer.getDesId();
        List<Integer> list=new ArrayList<>();
        Integer cuscount = customerService.count(desId);
        list.add(cuscount);
        Integer meacount = measureService.count(desId);
        list.add(meacount);
        Integer plancount = planService.count(desId);
        list.add(plancount);
        Integer concount = contractService.count(desId);
        list.add(concount);
        return list;
    }
}
